# author: Han Zhang
#########################################################################################
######################## Figure 6 in Appendix #################################

library(ggplot2)

DPI = 300
WIDTH = 7
UNIT = "in"


df3 <- read.csv('firststage_c1_SVM_NB.csv', sep = ',')

df3 = df3[df3$precision> 0.3,]
df3$f1 = with(df3, 2 * precision * recall /(precision + recall))
labels = c("Deep Learning", expression("Naive Bayes") ,"SVM")


ggplot(df3, aes(x = recall, y = precision, colour = label, linetype = label)) +
  geom_line(size = 2)+
  scale_color_manual (values = c("black",  "grey20", "grey50"),  labels = labels) + 
  scale_linetype_manual(values = c("solid",  "dotted", "dotdash"), labels = labels) +
  guides(colour = guide_legend(title = "Classifier"), linetype = guide_legend(title = "Classifier")) +
  theme_bw() +
  theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
        panel.background = element_blank(), axis.line = element_line(colour = "black")) +
  theme(axis.text = element_text(size = 20, colour = "black"),
        axis.title = element_text(size = 28, colour = "black"),
        plot.title = element_text(size = 20, colour = "black")) +
  theme(legend.text=element_text(size= 24),
        legend.key.width = unit(3, "line"),
        legend.key.height = unit(2, "line"),
        legend.title=element_text(size= 24)) +
  theme(legend.position = c(0.4, 0.2)) +
    theme(legend.text.align = 0) +
  ylim (0,1)


ggsave("firststage_c1_SVM_NB_precision_recall.pdf",
       dpi = DPI, width = WIDTH, height = WIDTH / 1.2, units = UNIT)

